<!--
*@Author: QWP
*@Description: 考勤日历
*@Date: 2024-07-10 18:04:59
-->
<template>
  <u-card title="考勤日历" class="f-h-100 u-check-card-calender">
    <a-calendar v-model:value="value" :fullscreen="false" mode="month" :headerRender="headerRender"
      class="u-check-calender" @panelChange="onPanelChange">
      <template #dateCellRender>
        <div :style="dateCelStyle">
          <div>
            值班
          </div>
        </div>
      </template>
    </a-calendar>
  </u-card>
</template>

<script lang='ts' setup>
import { ref, reactive, computed, onMounted } from 'vue'

import { useRoute, useRouter } from 'vue-router'
import { Dayjs } from 'dayjs';

const value = ref<Dayjs>();
const onPanelChange = (value: Dayjs, mode: string) => {
};

const dateCelStyle = reactive({
  height: '30px'
})

onMounted(() => {
  setPickerCellStyle()
  window.onresize = function () {
    setPickerCellStyle()
  }
})

// 设置单元格的高度样式
const setPickerCellStyle = () => {
  const calender = document.querySelector(".ant-picker-calendar")
  let allH = calender?.clientHeight - 48;
  let cellH = (allH / 6) - 36;
  dateCelStyle.height = cellH + "px"
}

const headerRender = () => {
  return ""
}

</script>

<style lang='scss'>
.u-check-card-calender {
  .ant-card-body {
    height: calc(100% - 32px) !important
  }

  .u-check-calender {
    height: 100%;

    .ant-picker-calendar {
      height: 100%;
    }

    .ant-picker-cell {
      border: 1px solid #E9E9E9;
    }
  }

  .ant-picker-content {
    thead th {
      height: 48px !important;
    }
  }

  .ant-picker-cell-inner {
    width: 100%;
    height: auto !important;

    .ant-picker-calendar-date-value {
      width: 24px;
      height: 24px;
    }
  }

  .ant-picker-cell-selected {
    .ant-picker-cell-inner {
      background-color: #fff !important;
      color: #1677ff !important;
    }
  }

  .ant-picker-calendar-date-today {
    &::before {
      border: none !important;
    }

    .ant-picker-calendar-date-value {
      border: 1px solid #1677ff;
      border-radius: 4px;
    }
  }
}
</style>